<?php

/**
 * This is the model class for table "{{page}}".
 *
 * The followings are the available columns in table '{{page}}':
 * @property integer $halaman_id
 * @property integer $top_halaman
 * @property integer $urut_halaman
 * @property string $nama_halaman
 * @property string $page_name
 * @property string $judul
 * @property string $title
 * @property string $content
 * @property string $isi_halaman
 * @property integer $gol_halaman
 * @property string $kategori_halaman
 * @property string $file_include
 * @property integer $status_halaman
 * @property string $tgl_halaman
 * @property string $ip_halaman
 * @property string $slug_id
 * @property string $slug_en
 */
class Page extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Page the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{page}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('top_halaman, urut_halaman, gol_halaman, status_halaman', 'numerical', 'integerOnly'=>true),
			array('nama_halaman, page_name, judul, title, file_include, slug_id, slug_en', 'length', 'max'=>255),
			array('kategori_halaman', 'length', 'max'=>2),
			array('tgl_halaman', 'length', 'max'=>14),
			array('ip_halaman', 'length', 'max'=>225),
			array('content, isi_halaman', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('halaman_id, top_halaman, urut_halaman, nama_halaman, page_name, judul, title, content, isi_halaman, gol_halaman, kategori_halaman, file_include, status_halaman, tgl_halaman, ip_halaman, slug_id, slug_en', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'halaman_id' => 'Halaman',
			'top_halaman' => 'Top Halaman',
			'urut_halaman' => 'Urut Halaman',
			'nama_halaman' => 'Nama Halaman',
			'page_name' => 'Page Name',
			'judul' => 'Judul',
			'title' => 'Title',
			'content' => 'Content',
			'isi_halaman' => 'Isi Halaman',
			'gol_halaman' => 'Gol Halaman',
			'kategori_halaman' => 'Kategori Halaman',
			'file_include' => 'File Include',
			'status_halaman' => 'Status Halaman',
			'tgl_halaman' => 'Tgl Halaman',
			'ip_halaman' => 'Ip Halaman',
			'slug_id' => 'Slug',
			'slug_en' => 'Slug En',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('halaman_id',$this->halaman_id);
		$criteria->compare('top_halaman',$this->top_halaman);
		$criteria->compare('urut_halaman',$this->urut_halaman);
		$criteria->compare('nama_halaman',$this->nama_halaman,true);
		$criteria->compare('page_name',$this->page_name,true);
		$criteria->compare('judul',$this->judul,true);
		$criteria->compare('title',$this->title,true);
		$criteria->compare('content',$this->content,true);
		$criteria->compare('isi_halaman',$this->isi_halaman,true);
		$criteria->compare('gol_halaman',$this->gol_halaman);
		$criteria->compare('kategori_halaman',$this->kategori_halaman,true);
		$criteria->compare('file_include',$this->file_include,true);
		$criteria->compare('status_halaman',$this->status_halaman);
		$criteria->compare('tgl_halaman',$this->tgl_halaman,true);
		$criteria->compare('ip_halaman',$this->ip_halaman,true);
		$criteria->compare('slug_id',$this->slug_id,true);
		$criteria->compare('slug_en',$this->slug_en,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
    /**
     * Behaviors for this model
     */
    public function behaviors(){
        return array(
            'sluggable' => array(
                'class'=>'ext.behaviors.SluggableBehavior.SluggableBehavior',
                'columns' => array('page_name'),
                'columnsId' => array('nama_halaman'),
                'unique' => true,
                'uniqueId' => true,
                'update' => true,
                'updateId' => true,
                'slugColumn' => 'slug_en',
                'slugColumnId' => 'slug_id'
            ),
        );
    }
}